*******************************************************************************************************************************************MANUSCRIPT: Authorized Generic Entry prior to Patent Expiry: Reassessing Incentives for Independent Generic Entry *AUTHOR:     Silvia Appelt, University of Munich, silvia.appelt@lrz.uni-muenchen.de******************************************************************************************************************************************	                               ***  Generate final data sets for regression analysis  ***						            		* Date last edit:  11 January 2015 * ******************************************************************************************************************************************   version 13.0set more offcap log closeclear****** Match NPI Data (relevant regression variables) with two Sets of Potential Generic Entrantsuse npi_human4.dta, clear keep sub_no_gentry_exp substances producer_no act_generics_no gentrant_no generic_entry_exp ind_generic_entry_exp ag_entry rx_switch sgp_all p_lit ///monopoly_effdur  atc3_rxsubstitutes_g atc3_rxsubstitutes_b pre_market_size2 ln_pre_market_size2 small medium large n_drugnewclass1 n_drugnewclass1n ///atc1_1 atc1_2 atc1_2 atc1_3 atc1_4 atc1_5 atc1_6 atc1_7 atc1_8 atc1_9 atc1_10 atc1_11 atc1_12 atc1_13 atc1_14 atc1_15 atc1_16 atc1_17 ///nfc1_1 nfc1_2 nfc1_2 nfc1_3 nfc1_4 nfc1_5 nfc1_6 nfc1_7 nfc1_8 nfc1_9 nfc1_10 nfc1_11 nfc1_12 nfc1_13 nfc1_14 nfc1_15 nfc1_16 nfc1_17 nfc1_18 ///oral_dum parenteral_dum topical_dum year2002 year2003 year2004 year2005 year2006 year2007 drop if sub_no_gentry_exp== .sort sub_no_gentry_exp producer_no save npi_human_regextract.dta, replacelocal setlist 1 2 foreach set in `setlist' {use npi_human_generic_entry`set', clear*(1) Data Matchingsort sub_no_gentry_exp producer_nomerge sub_no_gentry_exp producer_no using npi_human_regextract.dtatab _mtab _m*Assign Zero-Entries to companies that did not enterlocal list generic_entry_exp ind_generic_entry_exp  quietly foreach var of varlist `list' {replace `var'=0 if `var'== .}*AG Entry Dummy bysort sub_no_gentry_exp: egen ag_entry_dum=max(ag_entry)bysort sub_no_gentry_exp: egen ge_entry_dum=max(generic_entry_exp)sum ag_entry_dumsum ge_entry_dumcount if ag_entry_dum== .count if ge_entry_dum== .tab substances if ag_entry_dum==1tab substances if ag_entry_dum==0 & generic_entry_exp==1*Assign values to zero-entriescount if atc3_rxsubstitutes_g== . sum sub_no_gentry_exp, dlocal num=r(max)+1local x=1quietly while `x' <`num' {local list monopoly_effdur atc3_rxsubstitutes_g atc3_rxsubstitutes_b pre_market_size2 ln_pre_market_size2 small medium large n_drugnewclass1 n_drugnewclass1n ///atc1_1 atc1_2 atc1_2 atc1_3 atc1_4 atc1_5 atc1_6 atc1_7 atc1_8 atc1_9 atc1_10 atc1_11 atc1_12 atc1_13 atc1_14 atc1_15 atc1_16 atc1_17 ///nfc1_1 nfc1_2 nfc1_2 nfc1_3 nfc1_4 nfc1_5 nfc1_6 nfc1_7 nfc1_8 nfc1_9 nfc1_10 nfc1_11 nfc1_12 nfc1_13 nfc1_14 nfc1_15 nfc1_16 nfc1_17 nfc1_18 ///oral_dum parenteral_dum topical_dum year2002 year2003 year2004 year2005 year2006 year2007  quietly foreach var of varlist `list' {by sub_no_gentry_exp, sort: egen help_`x'=max(`var') if sub_no_gentry_exp==`x'by sub_no_gentry_exp, sort: replace `var'=help_`x' if sub_no_gentry_exp==`x' drop help*}local x=`x'+1}count if atc3_rxsubstitutes_g== . *(2) Independent generic entry decisions *Keep generic entrants/potential generic entrantssum act_generics_no gentrant_no egen entrant_no=group(producer_no) if act_generics_no!= . | gentrant_no!= .sum entrant_nocount if entrant_no== .count if entrant_no== . & generic_entry_exp==1drop if entrant_no== .drop _m*Delete zero-entries if generic entry actually occured (duplicate)by sub_no_gentry_exp producer_no, sort: egen check=mean(generic_entry_exp)tab checkby sub_no_gentry_exp producer_no, sort: egen check2=max(generic_entry_exp)by sub_no_gentry_exp producer_no, sort: egen check2b=max(ind_generic_entry_exp)count if generic_entry_exp!=check2 & check!=check2drop if generic_entry_exp!=check2 & check!=check2replace generic_entry_exp=check2replace ind_generic_entry_exp=check2bdrop check**drop duplicatesduplicates drop sub_no_gentry_exp producer_no, forcecount if generic_entry_exp==0count if generic_entry_exp==1count if ind_generic_entry_exp==0count if ind_generic_entry_exp==1*delete authorized generic entries count if ag_entry==1drop if ag_entry==1count if generic_entry_exp==0count if generic_entry_exp==1count if ind_generic_entry_exp==0count if ind_generic_entry_exp==1*Drop substances with no potential generic entrants (or generic entry)count if all_active==0tab sub_no_gentry_exp if all_active==0drop if all_active==0  count if generic_entry_exp==0count if generic_entry_exp==1count if ind_generic_entry_exp==0count if ind_generic_entry_exp==1count if ag_entry==0count if ag_entry==1drop ag_entry*(3) Potential generic entrants' therapeutic and drug form experiencesort sub_no_gentry_exp producer_nomerge sub_no_gentry_exp producer_no using npi_atc3_exp_merge.dtatab _mdrop if _m==2 drop _msort sub_no_gentry_exp producer_nomerge sub_no_gentry_exp producer_no using npi_nfc3_exp_merge.dtatab _mdrop if _m==2 drop _msum atc3_exp2 sum nfc3_exp2 duplicates dropegen help0=tag(sub_no_gentry_exp producer_no)egen help1=tag(sub_no_gentry_exp producer_no) if ind_generic_entry_exp==1egen help2=tag(sub_no_gentry_exp producer_no) if ind_generic_entry_exp==0by sub_no_gentry_exp, sort: egen total_entrants=total(help0)by sub_no_gentry_exp, sort: egen entrants=total(help1)by sub_no_gentry_exp, sort: egen zero_entrants=total(help2)drop help*sum *entrants, d*CHECKgen help=entrants+zero_entrantscount if help!=total_entrantsdrop helpcount if sub_no_gentry_exp== .count if sub_no_gentry_exp!= . & ag_entry_dum== .replace ag_entry_dum=0 if ag_entry_dum== . &  sub_no_gentry_exp!= .bysort sub_no_gentry_exp: egen help=max(ag_entry_dum)tab helpdrop help*assign drug namesreplace substances="Acamprosat" if sub_no_gentry_exp==1replace substances="Adapalen" if sub_no_gentry_exp==2replace substances="Alfuzosin" if sub_no_gentry_exp==3replace substances="Amisulprid" if sub_no_gentry_exp==4replace substances="Amlodipin" if sub_no_gentry_exp==5replace substances="Amorolfin" if sub_no_gentry_exp==6replace substances="Azithromycin" if sub_no_gentry_exp==7replace substances="Benazepril" if sub_no_gentry_exp==8replace substances="Cabergolin" if sub_no_gentry_exp==9replace substances="Calcipotriol" if sub_no_gentry_exp==10replace substances="Carmustin" if sub_no_gentry_exp==11replace substances="Carvedilol" if sub_no_gentry_exp==12replace substances="Cefixim" if sub_no_gentry_exp==13replace substances="Cefpodoxim" if sub_no_gentry_exp==14replace substances="Ceftazidim" if sub_no_gentry_exp==15replace substances="Ceftibuten" if sub_no_gentry_exp==16replace substances="Ceftriaxon" if sub_no_gentry_exp==17replace substances="Cilazapril" if sub_no_gentry_exp==18replace substances="Citalopram" if sub_no_gentry_exp==19replace substances="Clarithromycin" if sub_no_gentry_exp==20replace substances="Croconazol" if sub_no_gentry_exp==21replace substances="Didanosin" if sub_no_gentry_exp==22replace substances="Ebastin" if sub_no_gentry_exp==23replace substances="Epoetin alfa" if sub_no_gentry_exp==24replace substances="Fexofenadin" if sub_no_gentry_exp==25replace substances="Filgrastim" if sub_no_gentry_exp==26replace substances="Finasterid" if sub_no_gentry_exp==27replace substances="Fleroxacin" if sub_no_gentry_exp==28replace substances="Fluconazol" if sub_no_gentry_exp==29replace substances="Flumazenil" if sub_no_gentry_exp==30replace substances="Fosinopril" if sub_no_gentry_exp==31replace substances="Gabapentin" if sub_no_gentry_exp==32replace substances="Ganciclovir" if sub_no_gentry_exp==33replace substances="Glimepirid" if sub_no_gentry_exp==34replace substances="Granisetron" if sub_no_gentry_exp==35replace substances="Itraconazol" if sub_no_gentry_exp==36replace substances="Lacidipin" if sub_no_gentry_exp==37replace substances="Lamotrigin" if sub_no_gentry_exp==38replace substances="Lansoprazol" if sub_no_gentry_exp==39replace substances="Leuprorelin" if sub_no_gentry_exp==40replace substances="Lovastatin" if sub_no_gentry_exp==41replace substances="Meloxicam" if sub_no_gentry_exp==42replace substances="Miglitol" if sub_no_gentry_exp==43replace substances="Miltefosin" if sub_no_gentry_exp==44replace substances="Mirtazapin" if sub_no_gentry_exp==45replace substances="Molgramostim" if sub_no_gentry_exp==46replace substances="Moxonidin" if sub_no_gentry_exp==47replace substances="Nadifloxacin" if sub_no_gentry_exp==48replace substances="Nefazodon" if sub_no_gentry_exp==49replace substances="Olanzapin" if sub_no_gentry_exp==50replace substances="Ondansetron" if sub_no_gentry_exp==51replace substances="Oxycodon" if sub_no_gentry_exp==52replace substances="Paclitaxel" if sub_no_gentry_exp==53replace substances="Pamidrons�ure" if sub_no_gentry_exp==54replace substances="Pergolid" if sub_no_gentry_exp==55replace substances="Perindopril" if sub_no_gentry_exp==56replace substances="Pravastatin" if sub_no_gentry_exp==57replace substances="Prednicarbat" if sub_no_gentry_exp==58replace substances="Quinagolid" if sub_no_gentry_exp==59replace substances="Quinapril" if sub_no_gentry_exp==60replace substances="Ramipril" if sub_no_gentry_exp==61replace substances="Risperidon" if sub_no_gentry_exp==62replace substances="Sertaconazol" if sub_no_gentry_exp==63replace substances="Sertralin" if sub_no_gentry_exp==64replace substances="Simvastatin" if sub_no_gentry_exp==65replace substances="Sumatriptan" if sub_no_gentry_exp==66replace substances="Tamsulosin" if sub_no_gentry_exp==67replace substances="Temozolomid" if sub_no_gentry_exp==68replace substances="Terazosin" if sub_no_gentry_exp==69replace substances="Terbinafin" if sub_no_gentry_exp==70replace substances="Torasemid" if sub_no_gentry_exp==71replace substances="Toremifen" if sub_no_gentry_exp==72replace substances="Trandolapril" if sub_no_gentry_exp==73replace substances="Tropisetron" if sub_no_gentry_exp==74replace substances="Zidovudin" if sub_no_gentry_exp==75count if substances==""drop if sub_no_gentry_exp==22drop if sub_no_gentry_exp==75*Note: 2 drug are excluded from the analysis as no (potential) entrants were identified in second set of potential entrants *=>econometric analysis confined to 73 drug markets (first and second set of potential generic entrants)countdrop sub_id sub_no hst_id producer act_generics_no all_active gentrant_nocompresssave npi_human_biprobit_firms`set'_final, replace}erase npi_human_regextract.dtaerase npi_human3_firm_effects.dtaerase npi_atc3_exp_merge.dtaerase npi_nfc3_exp_merge.dtaerase npi_pholder.dtaerase npi_drug.dtaerase npi_drug_tn.dta*** end of do file